﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twi.DataAccess.OutInterface;

namespace Twi.COMMON.Module
{
    /*
     * Copyright: ©2013 Tyingsoft
     * Create By:xuzhihong
     * Create Date: 2013-10-14
     * Description: 访问任何数据库（指不同连接字符串）通用方法所用的DB
     */

    public class AnyConnection : TwiModuleHelper, IPageCommon
    {
        public AnyConnection() { }
        public AnyConnection(AnyConnInitConfig initConfig)
        {
            if (initConfig != null)
            {
                ConfigConnectionString = initConfig.ConfigConnectionString;
                MappingTableName = initConfig.MappingTableName;
                SQLMapFullPath = initConfig.SQLMapFullPath;
                MaxCode = initConfig.MaxCode;
                WebConfigPath = initConfig.WebConfigPath;
            }            
        }
        /// <summary>
        /// 简单构造函数
        /// </summary>
        /// <param name="code">项目英文缩写如：BIM</param>
        public AnyConnection(string code)
        {
            AnyConnInitConfig initConfig = new AnyConnInitConfig();
            if (!string.IsNullOrEmpty(code))
            {
                initConfig.ConfigConnectionString = AnyConnInitConfig.AddPostfix(code);
            }
            if (initConfig != null)
            {
                ConfigConnectionString = initConfig.ConfigConnectionString;
                MappingTableName = initConfig.MappingTableName;
                SQLMapFullPath = initConfig.SQLMapFullPath;
                MaxCode = initConfig.MaxCode;
                WebConfigPath = initConfig.WebConfigPath;
            }  
        }
    }    
}
